<template>
  <div class="app-container">
    <!--数据表-->
    <el-table ref="tableContainer" v-loading="loading" :data="recordHistoryList" stripe border highlight-current-row height="680">
      <!--空状态时的占位提示-->
      <template slot="empty">
        <el-empty>
          <el-button type="primary" @click="resetQuery">刷新试试</el-button>
        </el-empty>
      </template>
      <el-table-column width="50" align="center">
        <template slot-scope="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="类别" align="center" prop="category" width="360">
        <template slot-scope="scope">
          <el-tooltip
            effect="dark"
            :disabled="true"
            :content="formatContent(scope.row.category)"
            placement="top-start">
            <span class="cell-content" :title="scope.row.category">
              {{ formatDisplayText(scope.row.category) }}
            </span>
          </el-tooltip>
        </template>
      </el-table-column>

      <el-table-column label="工艺要点" align="center" prop="process">
        <template slot-scope="scope">
          <el-tooltip
            effect="dark"
            :disabled="true"
            :content="formatContent(scope.row.process)"
            placement="top-start">
            <span class="cell-content" :title="scope.row.process">
              {{ formatDisplayText(scope.row.process) }}
            </span>
          </el-tooltip>
        </template>
      </el-table-column>

      <el-table-column label="展示时间" align="center" prop="disTime" width="200" sortable/>
      <el-table-column label="消失时间" align="center" prop="doneTime" width="200" sortable/>
    </el-table>

    <!--分页-->
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listRecordHistory } from "@/api/showcase/showcase_1580/recordHistory1580";

export default {
  name: "RecordHistory1580",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 工艺要点管理 表格数据
      recordHistoryList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        currentUser: sessionStorage.getItem("currentUser"),
      },

    };
  },

  created() {
    this.getList();
  },


  methods: {
    /** 查询展示台 列表 */
    getList() {
      this.loading = true;
      listRecordHistory(this.queryParams).then(response => {
        this.recordHistoryList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    // 鼠标悬停显示格式化文字
    formatDisplayText(text) {
      if (text && text.length > 60) {
        return text.slice(0, 60) + '...';
      }
      return text;
    },
    formatContent(text) {
      return text ? text.replace(/\n/g, '<br>') : '';
    },


  }
};
</script>

<style scoped>
.cell-content { /*表格内文字防溢出 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

</style>
